WorkerScript.onMessage = function(message) {
    doLogout(message);
}

function doLogout(message) {
//    Qt.include("G.js");
//    var username = message.username;
//    var password = message.password;
//    var xhr = new XMLHttpRequest;
//    var url = "https://production-2.sogeoapi.com/oauth/access_token?grant_type=password&client_id=" + gClientId + "&client_secret=" + gClientSecret +
//        "&username=" + username + "&password=" + password;
//    xhr.open("GET", url);
//    xhr.onreadystatechange = function() {
//        console.log("REQUEST: " + url);
//        console.log("RESPONSE: " + xhr.responseText);
//        if (xhr.readyState == XMLHttpRequest.DONE) {
//            var response = JSON.parse(xhr.responseText);
//            WorkerScript.sendMessage({ 'token': response.access_token });
//            gToken = response.access_token;
//        }
//    }
//    xhr.send();
    WorkerScript.sendMessage({ 'token': message.g.defaultToken });
}
